package com.javaclimb.accounting.service.impl;

import com.javaclimb.accounting.dao.AccountDao;
import com.javaclimb.accounting.po.Account;
import com.javaclimb.accounting.po.User;
import com.javaclimb.accounting.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @description:
 * @author: XX
 * @create: 2022-12-28 18:46
 **/

@Service
public class AccountServiceImpl implements AccountService {
    @Autowired
    private AccountDao accountDao;

    @Override
    public Account findByUserAccId(long userAccId) {
        return accountDao.findByUserAccId(userAccId);
    }
    /**
     * 查询用户余额
     * @param userName
     * @return
     */
    @Override
    public Account queryBalance(String userName) {
        //查用户
        User user = accountDao.queryUser(userName);
        //根据用户表的电子账户id查电子账户
        Account account = accountDao.queryAccount(user.getUserAccId());
        return account;
    }




}
